package com.situ.crm.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.swing.plaf.synth.SynthStyle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.crm.common.ServerResponse;
import com.situ.crm.entity.CusDevPlan;
import com.situ.crm.entity.CustomerLossMeasure;
import com.situ.crm.service.ICustomerLossMeasureService;

@Controller
@RequestMapping(value="lossMeasure")
public class CustomerLossMeasureController {
	@Autowired
	private ICustomerLossMeasureService customerLossMeasureService;
	
	@RequestMapping(value="/getLossMeasurePage")
	public String getLossMeasurePage(Integer id,Model model) {
		model.addAttribute("id",id);
		return "customer_loss_measure/customerLossMeasure_list";
	}
	
	//查出对应的暂缓流失计划
	@RequestMapping(value="/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer limit,Integer page,Integer id) {
		System.err.println(id);
		ServerResponse serverResponse = customerLossMeasureService.pageList(limit,page,id);
		return serverResponse;
	}
	
	//添加页面
	@RequestMapping(value="/getAddPage")
	public String getAddPage(Integer id,Model model) {
		model.addAttribute("id",id);
		return "customer_loss_measure/customerLossMeasure_insert";
	}
	
	//添加功能
	@RequestMapping(value="/insert")
	@ResponseBody
	public ServerResponse insert(CustomerLossMeasure customerLossMeasure) {
		return customerLossMeasureService.insert(customerLossMeasure);
	}
	
	//删除功能
	@RequestMapping(value="/deleteById")
	@ResponseBody
	public ServerResponse deleteById(Integer id) {
		return customerLossMeasureService.deleteById(id);
	}
	
	//批量删除
	@RequestMapping(value="/deleteAll")
	@ResponseBody
	public ServerResponse deleteAll(String ids) {
		return customerLossMeasureService.deleteAll(ids);
	}
	
	//修改页面
	@RequestMapping(value="/getUpdatePage")
	public String getUpdatePage(Integer id,Model model){
		CustomerLossMeasure customerLossMeasure = customerLossMeasureService.selectById(id);
		
		model.addAttribute("customerLossMeasure",customerLossMeasure);
		return "customer_loss_measure/customerLossMeasure_update";
	}
	
	//修改
	@RequestMapping(value="/update")
	@ResponseBody
	public ServerResponse update(CustomerLossMeasure customerLossMeasure) {
		return customerLossMeasureService.updata(customerLossMeasure);
	}
}
